function getCode() {
   if(!this.checkPhone()){return false}
    $.ajax({
        async: false,
        type: "GET",
        url: " ",
        data: {
            mobile: $("#phone").val()
        },
        dataType: "json",
        async: false,
        success: function (data) {
            console.log(data);
            settime();
        },
        error: function (err) {
            console.log(err);
        }
    });
    // 验证码获取时间
    var countdown = 60;
    var phone_code = $(".phone_code");

    function settime() {
        if (countdown == 0) {
            $(".phone_code").attr("disabled", false);
            $(".phone_code").text("获取验证码");
            $(".phone_code").removeClass('is_send');
            countdown = 60;
            return false;
        } else {
            $(".phone_code").attr("disabled", true);
            $(".phone_code").addClass('is_send');
            $(".phone_code").text("重新发送(" + countdown + ")");
            countdown--;
        }
        setTimeout(function () {
            settime();
        }, 1000);
    }
}

function checkPhone() {
    var phone = $('#phone').val()
    // var mobilevalid = /^(0|86|17951)?(13[0-9]|15[012356789]|17[0678]|18[0-9]|14[57])[0-9]{8}$/;
    var phoneValid = /^1[345678][0-9]{9}$/;
    if (!phoneValid.test(phone)) {
        alert('请输入正确的手机号码！');
        return false;
    }else{return true}
}

function login() {
    let result= this.checkPhone();
    if (!result) {
        return false;
    }
    if ($('#code').val().trim() == "") {
        alert('请输入验证码');
        return false;
    }
    $.ajax({
        async: false,
        type: "GET",
        url: " ",
        data: {
            phone: $("#phone").val(),
            code: $('#code').val()
        },
        dataType: "json",
        async: false,
        success: function (data) {
            console.log(data);
            settime();
        },
        error: function (err) {
            console.log(err);
        }
    });
}